preexperiment_date <- "08 May 2023 11 04AM/All"
postexperiment_date <- "08 May 2023 05 12PM/All"
##--- last fish run in trial ---##
experiment_date <- "08 May 2023 01 47PM/Oxygen"
experiment_date2 <- "08 May 2023 01 47PM/All"
firesting <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19)
Cycle_1 <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE)
Cycle_last <-read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_date2,"slopes/Cycle_21.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) preexperiment_date_asus <- "08 May 2023 11 14AM/All"
postexperiment_date_asus <- "08 May 2023 05 03PM/All"
##--- last fish run in trial ---##
experiment_date_asus <- "08 May 2023 01 32PM/Oxygen"
experiment_date2_asus <- "08 May 2023 01 32PM/All"
firesting_asus <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19)
Cycle_1_asus <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE)
Cycle_last_asus <-read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date2_asus,"slopes/Cycle_21.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) chamber1_dell = 0.04650
chamber2_dell = 0.04593
chamber3_dell = 0.04977
chamber4_dell = 0.04860
chamber1_asus = 0.04565
chamber2_asus = 0.04573
chamber3_asus = 0.04551
chamber4_asus = 0.04791
Date_tested="2023-05-08"
Clutch = "092"
Male = "CSUD002"
Female = "CSUD213"
Population = "Sudbury reef"
Tank =213
salinity =36
Date_analysed = Sys.Date() Replicate = 1
mass = 0.0004642
chamber = "ch4"
Swim = "good/good"
chamber_vol = chamber4_dell
system1 = "Dell"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "08 May 2023 12 45PM/Oxygen"
experiment_mmr_date2 <- "08 May 2023 12 45PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -6.842446e-05
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.003611091
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.17
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 3 4 9 12 13 15 16 17 20 22 26 27 28 29 30 37 41 42 43 44
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 1.37
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 7 1 371.9595 -0.02070951 0.999 NA 3002 3236 13200.23
## 2: 16 1 511.8177 -0.02286772 0.999 NA 7450 7684 18060.36
## 3: 17 1 524.7107 -0.02290194 0.999 NA 7945 8179 18601.08
## 4: 18 1 538.1340 -0.02295886 0.999 NA 8439 8672 19140.63
## 5: 19 1 548.8358 -0.02286285 0.999 NA 8933 9166 19681.04
## 6: 21 1 574.1758 -0.02290400 0.998 NA 9921 10155 20760.42
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 13455.79 98.690 93.151 -0.02070951 -0.001631318 -0.01907819 -0.01907819
## 2: 18316.05 98.732 92.954 -0.02286772 -0.003326842 -0.01954088 -0.01954088
## 3: 18856.70 98.586 92.947 -0.02290194 -0.003515465 -0.01938648 -0.01938648
## 4: 19395.94 98.627 92.742 -0.02295886 -0.003703638 -0.01925523 -0.01925523
## 5: 19935.60 98.817 93.012 -0.02286285 -0.003892034 -0.01897082 -0.01897082
## 6: 21015.94 98.570 92.783 -0.02290400 -0.004268753 -0.01863525 -0.01863525
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0486 0.0004642 NA 36 28.5 1.013253 -0.2114526
## 2: %Air sec 0.0486 0.0004642 NA 36 28.5 1.013253 -0.2165808
## 3: %Air sec 0.0486 0.0004642 NA 36 28.5 1.013253 -0.2148695
## 4: %Air sec 0.0486 0.0004642 NA 36 28.5 1.013253 -0.2134148
## 5: %Air sec 0.0486 0.0004642 NA 36 28.5 1.013253 -0.2102625
## 6: %Air sec 0.0486 0.0004642 NA 36 28.5 1.013253 -0.2065432
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -455.5206 NA mgO2/hr/kg -455.5206
## 2: -466.5678 NA mgO2/hr/kg -466.5678
## 3: -462.8814 NA mgO2/hr/kg -462.8814
## 4: -459.7475 NA mgO2/hr/kg -459.7475
## 5: -452.9568 NA mgO2/hr/kg -452.9568
## 6: -444.9445 NA mgO2/hr/kg -444.9445
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 1 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0004642 | ch4 | Dell | 0.0486 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 459.5348 | 0.213316 | 0.999 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.00
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 6 8 9 10 12 13 14 15 16 17 20 23 26 27 29 30
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.08 1.35
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 413.8650 -0.05078854 0.9989633 NA 64 118 6257.32
## 2: NA 2 413.6092 -0.05074809 0.9989239 NA 63 117 6256.23
## 3: NA 3 413.5305 -0.05073547 0.9988559 NA 56 110 6248.55
## 4: NA 4 413.3840 -0.05071228 0.9989215 NA 62 116 6255.10
## 5: NA 5 413.1561 -0.05067571 0.9989108 NA 65 119 6258.43
## ---
## 211: NA 211 345.8742 -0.03990520 0.9960012 NA 5 59 6191.24
## 212: NA 212 344.9864 -0.03976260 0.9958644 NA 4 58 6190.16
## 213: NA 213 344.1007 -0.03962039 0.9956509 NA 3 57 6188.96
## 214: NA 214 343.2373 -0.03948170 0.9954788 NA 2 56 6187.86
## 215: NA 215 341.7803 -0.03924740 0.9953628 NA 1 55 6186.74
## endtime oxy endoxy rate
## 1: 6317.32 96.044 93.046 -0.05078854
## 2: 6316.23 96.135 93.066 -0.05074809
## 3: 6308.55 96.507 93.433 -0.05073547
## 4: 6315.10 96.157 93.130 -0.05071228
## 5: 6318.43 96.041 93.010 -0.05067571
## ---
## 211: 6251.24 98.781 96.399 -0.03990520
## 212: 6250.16 98.807 96.458 -0.03976260
## 213: 6248.96 98.852 96.503 -0.03962039
## 214: 6247.86 98.881 96.507 -0.03948170
## 215: 6246.74 98.939 96.504 -0.03924740
##
## Regressions : 215 | Results : 215 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 215 adjusted rate(s):
## Rate : -0.05078854
## Adjustment : -6.842446e-05
## Adjusted Rate : -0.05072011
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 215 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 214 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 413.865 -0.05078854 0.9989633 NA 64 118 6257.32
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 6317.32 96.044 93.046 -0.05078854 -6.842446e-05 -0.05072011 -0.05072011
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0486 0.0004642 NA 36 28.5 1.013253 -0.562155
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1211.019 NA mgO2/hr/kg -1211.019
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 1 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0004642 | ch4 | Dell | 0.0486 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 459.5348 | 0.213316 | 0.999 | 1211.019 | 0.562155 | 0.9989633 | 751.4842 | 0.348839 |
## Rows: 139 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 2
mass = 0.0006061
chamber = "ch3"
Swim = "good/good"
chamber_vol = chamber3_dell
system1 = "Dell"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "08 May 2023 01 47PM/Oxygen"
experiment_mmr_date2 <- "08 May 2023 01 47PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0007771546
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.003364904
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.17
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 3 4 9 12 13 15 16 17 20 22 26 27 28 29 30 37 41 42 43 44
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 1.37
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 13 1 423.4473 -0.01975701 0.992 NA 5968 6201 16440.63
## 2: 14 1 419.7948 -0.01887507 0.994 NA 6462 6696 16980.52
## 3: 16 1 445.2106 -0.01916129 0.991 NA 7450 7684 18060.36
## 4: 17 1 412.6893 -0.01686051 0.987 NA 7945 8179 18601.08
## 5: 20 1 531.7629 -0.02138029 0.985 NA 9427 9661 20220.78
## 6: 21 1 538.6047 -0.02117279 0.994 NA 9921 10155 20760.42
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 16695.22 98.988 93.495 -0.01975701 -0.002744386 -0.01701262 -0.01701262
## 2: 17235.95 99.202 94.597 -0.01887507 -0.002882070 -0.01599300 -0.01599300
## 3: 18316.05 99.122 93.983 -0.01916129 -0.003157274 -0.01600401 -0.01600401
## 4: 18856.70 99.052 94.347 -0.01686051 -0.003295054 -0.01356545 -0.01356545
## 5: 20476.12 99.022 93.787 -0.02138029 -0.003707759 -0.01767253 -0.01767253
## 6: 21015.94 99.007 93.715 -0.02117279 -0.003845295 -0.01732750 -0.01732750
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04977 0.0006061 NA 36 28.5 1.013253 -0.1930983
## 2: %Air sec 0.04977 0.0006061 NA 36 28.5 1.013253 -0.1815253
## 3: %Air sec 0.04977 0.0006061 NA 36 28.5 1.013253 -0.1816503
## 4: %Air sec 0.04977 0.0006061 NA 36 28.5 1.013253 -0.1539719
## 5: %Air sec 0.04977 0.0006061 NA 36 28.5 1.013253 -0.2005885
## 6: %Air sec 0.04977 0.0006061 NA 36 28.5 1.013253 -0.1966722
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -318.5915 NA mgO2/hr/kg -318.5915
## 2: -299.4973 NA mgO2/hr/kg -299.4973
## 3: -299.7035 NA mgO2/hr/kg -299.7035
## 4: -254.0372 NA mgO2/hr/kg -254.0372
## 5: -330.9495 NA mgO2/hr/kg -330.9495
## 6: -324.4881 NA mgO2/hr/kg -324.4881
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 2 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0006061 | ch3 | Dell | 0.04977 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 314.646 | 0.1907069 | 0.9912 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.17
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 3 4 9 12 13 15 16 17 20 22 26 27 28 29 30 37 41 42 43 44
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.08 1.37
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 695.5184 -0.05969224 0.9975233 NA 190 245 10124.66
## 2: NA 2 695.1163 -0.05965276 0.9975432 NA 191 246 10125.77
## 3: NA 3 694.0496 -0.05954773 0.9975383 NA 192 247 10126.97
## 4: NA 4 693.9390 -0.05953658 0.9976044 NA 189 244 10123.58
## 5: NA 5 692.1925 -0.05936456 0.9976002 NA 188 243 10122.49
## ---
## 214: NA 214 253.4989 -0.01591581 0.9704271 NA 96 151 10020.95
## 215: NA 215 251.7358 -0.01573945 0.9736529 NA 92 147 10016.53
## 216: NA 216 251.7101 -0.01573756 0.9730424 NA 95 150 10019.86
## 217: NA 217 250.5070 -0.01561736 0.9751388 NA 93 148 10017.62
## 218: NA 218 250.0174 -0.01556885 0.9757376 NA 94 149 10018.77
## endtime oxy endoxy rate
## 1: 10184.66 91.182 87.500 -0.05969224
## 2: 10185.77 91.170 87.487 -0.05965276
## 3: 10186.97 91.090 87.465 -0.05954773
## 4: 10183.58 91.209 87.595 -0.05953658
## 5: 10182.49 91.198 87.681 -0.05936456
## ---
## 214: 10080.95 94.037 92.934 -0.01591581
## 215: 10076.53 94.215 93.159 -0.01573945
## 216: 10079.86 94.058 92.960 -0.01573756
## 217: 10077.62 94.163 93.094 -0.01561736
## 218: 10078.77 94.120 93.057 -0.01556885
##
## Regressions : 218 | Results : 218 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 218 adjusted rate(s):
## Rate : -0.05969224
## Adjustment : -0.0007771546
## Adjusted Rate : -0.05891509
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 33 rate(s) removed, 185 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 184 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 695.5184 -0.05969224 0.9975233 NA 190 245 10124.66
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 10184.66 91.182 87.5 -0.05969224 -0.0007771546 -0.05891509 -0.05891509
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04977 0.0006061 NA 36 28.5 1.013253 -0.6687038
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1103.289 NA mgO2/hr/kg -1103.289
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 2 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0006061 | ch3 | Dell | 0.04977 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 314.646 | 0.1907069 | 0.9912 | 1103.289 | 0.6687038 | 0.9975233 | 788.6435 | 0.4779968 |
## Rows: 140 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): Clutch, Male, Female, Population, Chamber, System, Date_tested, Sw...
## dbl (15): Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Temperatur...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 3
mass = 0.0007843
chamber = "ch2"
Swim = "good/good"
chamber_vol = chamber2_dell
system1 = "Dell"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "08 May 2023 12 24PM/Oxygen"
experiment_mmr_date2 <- "08 May 2023 12 24PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -2.496878e-05
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.002906364
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.17
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 3 4 9 12 13 15 16 17 20 22 26 27 28 29 30 37 41 42 43 44
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 1.37
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 3 1 489.2386 -0.03558088 0.999 NA 1026 1259 11040.48
## 2: 4 1 500.4248 -0.03486478 0.998 NA 1520 1753 11580.96
## 3: 17 1 819.9015 -0.03887278 0.999 NA 7945 8179 18601.08
## 4: 18 1 821.4182 -0.03785477 0.999 NA 8439 8672 19140.63
## 5: 20 1 885.1140 -0.03898182 0.999 NA 9427 9661 20220.78
## 6: 21 1 867.2090 -0.03713194 0.998 NA 9921 10155 20760.42
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 11295.45 96.494 87.519 -0.03558088 -0.0006832392 -0.03489764 -0.03489764
## 2: 11835.58 96.475 88.118 -0.03486478 -0.0008365462 -0.03402823 -0.03402823
## 3: 18856.70 96.850 87.079 -0.03887278 -0.0028285877 -0.03604419 -0.03604419
## 4: 19395.94 96.863 87.184 -0.03785477 -0.0029816364 -0.03487313 -0.03487313
## 5: 20476.12 96.934 86.935 -0.03898182 -0.0032881241 -0.03569370 -0.03569370
## 6: 21015.94 96.555 87.076 -0.03713194 -0.0034412679 -0.03369067 -0.03369067
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04593 0.0007843 NA 36 28.5 1.013253 -0.3655376
## 2: %Air sec 0.04593 0.0007843 NA 36 28.5 1.013253 -0.3564310
## 3: %Air sec 0.04593 0.0007843 NA 36 28.5 1.013253 -0.3775473
## 4: %Air sec 0.04593 0.0007843 NA 36 28.5 1.013253 -0.3652809
## 5: %Air sec 0.04593 0.0007843 NA 36 28.5 1.013253 -0.3738760
## 6: %Air sec 0.04593 0.0007843 NA 36 28.5 1.013253 -0.3528951
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -466.0687 NA mgO2/hr/kg -466.0687
## 2: -454.4574 NA mgO2/hr/kg -454.4574
## 3: -481.3812 NA mgO2/hr/kg -481.3812
## 4: -465.7413 NA mgO2/hr/kg -465.7413
## 5: -476.7002 NA mgO2/hr/kg -476.7002
## 6: -449.9492 NA mgO2/hr/kg -449.9492
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 3 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0007843 | ch2 | Dell | 0.04593 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 468.8698 | 0.3677346 | 0.9988 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.08 1.92
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 2 4 5 6 7 8 10 12 13 14 15 17 18 19 20 21 22 23 25 26
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.08 1.36
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 594.4998 -0.10018645 0.9919424 NA 45 98 4979.95
## 2: NA 2 594.1493 -0.10011346 0.9917766 NA 46 99 4981.05
## 3: NA 3 593.5179 -0.09999328 0.9913954 NA 44 97 4978.61
## 4: NA 4 592.6349 -0.09980858 0.9910291 NA 47 100 4982.13
## 5: NA 5 590.8641 -0.09946591 0.9901313 NA 43 96 4977.52
## ---
## 205: NA 205 346.3533 -0.05115226 0.9976143 NA 205 258 5164.72
## 206: NA 206 344.6814 -0.05083065 0.9977762 NA 206 259 5165.81
## 207: NA 207 342.6817 -0.05044600 0.9979259 NA 207 260 5167.13
## 208: NA 208 340.9487 -0.05011251 0.9977856 NA 208 261 5168.23
## 209: NA 209 339.4358 -0.04982164 0.9978894 NA 209 262 5169.32
## endtime oxy endoxy rate
## 1: 5039.95 95.172 89.884 -0.10018645
## 2: 5041.05 95.124 89.883 -0.10011346
## 3: 5038.61 95.224 89.884 -0.09999328
## 4: 5042.13 95.127 89.817 -0.09980858
## 5: 5037.52 95.302 89.924 -0.09946591
## ---
## 205: 5224.72 82.342 79.122 -0.05115226
## 206: 5225.81 82.303 79.107 -0.05083065
## 207: 5227.13 82.219 79.071 -0.05044600
## 208: 5228.23 82.163 79.044 -0.05011251
## 209: 5229.32 82.052 78.958 -0.04982164
##
## Regressions : 209 | Results : 209 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 209 adjusted rate(s):
## Rate : -0.1001864
## Adjustment : -2.496878e-05
## Adjusted Rate : -0.1001615
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 209 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 208 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 594.4998 -0.1001864 0.9919424 NA 45 98 4979.95
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 5039.95 95.172 89.884 -0.1001864 -2.496878e-05 -0.1001615 -0.1001615
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04593 0.0007843 NA 36 28.5 1.013253 -1.049148
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1337.687 NA mgO2/hr/kg -1337.687
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 3 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0007843 | ch2 | Dell | 0.04593 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 468.8698 | 0.3677346 | 0.9988 | 1337.687 | 1.049148 | 0.9919424 | 868.8174 | 0.6814135 |
## Rows: 141 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): Clutch, Male, Female, Population, Chamber, System, Date_tested, Sw...
## dbl (15): Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Temperatur...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 4
mass = 0.0003903
chamber = "ch1"
Swim = "good/good"
chamber_vol = chamber1_dell
system1 = "Dell"
Notes="check max"
##--- time of trail ---##
experiment_mmr_date <- "08 May 2023 01 35PM/Oxygen"
experiment_mmr_date2 <- "08 May 2023 01 35PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.001097468
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.003003284
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.17
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 3 4 9 12 13 15 16 17 20 22 26 27 28 29 30 37 41 42 43 44
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 1.37
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 5 1 350.1172 -0.02085368 0.994 NA 2014 2248 12120.43
## 2: 7 1 350.4117 -0.01915261 0.995 NA 3002 3236 13200.23
## 3: 8 1 358.3423 -0.01899016 0.994 NA 3497 3731 13740.88
## 4: 9 1 370.9071 -0.01912799 0.998 NA 3991 4225 14280.52
## 5: 11 1 425.7357 -0.02136298 0.993 NA 4980 5214 15360.95
## 6: 21 1 557.9915 -0.02222456 0.994 NA 9921 10155 20760.42
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 12376.17 97.570 92.101 -0.02085368 -0.001735612 -0.01911807 -0.01911807
## 2: 13455.79 97.513 92.807 -0.01915261 -0.001938244 -0.01721437 -0.01721437
## 3: 13996.40 97.647 92.575 -0.01899016 -0.002039705 -0.01695046 -0.01695046
## 4: 14536.13 97.718 92.898 -0.01912799 -0.002140989 -0.01698700 -0.01698700
## 5: 15616.55 97.509 91.745 -0.02136298 -0.002343755 -0.01901922 -0.01901922
## 6: 21015.94 96.932 90.953 -0.02222456 -0.003357080 -0.01886748 -0.01886748
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0465 0.0003903 NA 36 28.5 1.013253 -0.2027387
## 2: %Air sec 0.0465 0.0003903 NA 36 28.5 1.013253 -0.1825508
## 3: %Air sec 0.0465 0.0003903 NA 36 28.5 1.013253 -0.1797521
## 4: %Air sec 0.0465 0.0003903 NA 36 28.5 1.013253 -0.1801396
## 5: %Air sec 0.0465 0.0003903 NA 36 28.5 1.013253 -0.2016904
## 6: %Air sec 0.0465 0.0003903 NA 36 28.5 1.013253 -0.2000813
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -519.4432 NA mgO2/hr/kg -519.4432
## 2: -467.7191 NA mgO2/hr/kg -467.7191
## 3: -460.5486 NA mgO2/hr/kg -460.5486
## 4: -461.5413 NA mgO2/hr/kg -461.5413
## 5: -516.7575 NA mgO2/hr/kg -516.7575
## 6: -512.6347 NA mgO2/hr/kg -512.6347
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 4 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0003903 | ch1 | Dell | 0.0465 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 495.6192 | 0.1934402 | 0.9948 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.17
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 3 4 5 6 7 8 9 10 16 20 21 22 23 24 25 26 27 29 31 32
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 2.09
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 505.9302 -0.04444423 0.9971547 NA 17 72 9207.06
## 2: NA 2 505.6775 -0.04441660 0.9970941 NA 18 73 9208.14
## 3: NA 3 505.0427 -0.04434835 0.9969708 NA 16 71 9205.83
## 4: NA 4 504.6099 -0.04430143 0.9969022 NA 13 68 9202.40
## 5: NA 5 504.4070 -0.04427887 0.9968371 NA 19 74 9209.23
## ---
## 210: NA 210 300.0627 -0.02238852 0.9735294 NA 164 219 9372.50
## 211: NA 211 299.6210 -0.02234067 0.9745548 NA 160 215 9368.00
## 212: NA 212 298.2426 -0.02219465 0.9747971 NA 163 218 9371.42
## 213: NA 213 297.7640 -0.02214347 0.9750962 NA 162 217 9370.18
## 214: NA 214 297.5252 -0.02211784 0.9752134 NA 161 216 9369.09
## endtime oxy endoxy rate
## 1: 9267.06 96.679 94.088 -0.04444423
## 2: 9268.14 96.648 94.095 -0.04441660
## 3: 9265.83 96.762 94.102 -0.04434835
## 4: 9262.40 96.920 94.264 -0.04430143
## 5: 9269.23 96.648 94.064 -0.04427887
## ---
## 210: 9432.50 90.260 88.762 -0.02238852
## 211: 9428.00 90.441 89.043 -0.02234067
## 212: 9431.42 90.321 88.834 -0.02219465
## 213: 9430.18 90.344 88.881 -0.02214347
## 214: 9429.09 90.421 88.994 -0.02211784
##
## Regressions : 214 | Results : 214 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 214 adjusted rate(s):
## Rate : -0.04444423
## Adjustment : -0.001097468
## Adjusted Rate : -0.04334676
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 214 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 213 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 505.9302 -0.04444423 0.9971547 NA 17 72 9207.06
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 9267.06 96.679 94.088 -0.04444423 -0.001097468 -0.04334676 -0.04334676
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0465 0.0003903 NA 36 28.5 1.013253 -0.4596732
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1177.743 NA mgO2/hr/kg -1177.743
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 4 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0003903 | ch1 | Dell | 0.0465 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 495.6192 | 0.1934402 | 0.9948 | 1177.743 | 0.4596732 | 0.9971547 | 682.1242 | 0.2662331 | check max |
## Rows: 142 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): Clutch, Male, Female, Population, Chamber, System, Date_tested, Sw...
## dbl (15): Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Temperatur...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 5
mass = 0.0003965
chamber = "ch4"
Swim = "good/good"
chamber_vol = chamber4_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "08 May 2023 12 59PM/Oxygen"
experiment_mmr_date2_asus <- "08 May 2023 12 59PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0002379482
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.004158683
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.08
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.08
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 8 1 332.8602 -0.01925381 0.960 NA 2718 2890 12203.14
## 2: 11 1 367.1696 -0.01944669 0.970 NA 3842 4029 13823.23
## 3: 12 1 337.3282 -0.01665214 0.982 NA 4238 4425 14362.96
## 4: 14 1 379.2035 -0.01823377 0.981 NA 5031 5218 15443.31
## 5: 16 1 451.7853 -0.02140343 0.993 NA 5823 6011 16522.79
## 6: 19 1 505.3252 -0.02243751 0.977 NA 7013 7201 18142.79
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 12457.98 97.776 92.309 -0.01925381 -0.003352857 -0.01590096 -0.01590096
## 2: 14078.06 98.017 92.955 -0.01944669 -0.004146748 -0.01529994 -0.01529994
## 3: 14618.03 97.877 93.535 -0.01665214 -0.004411291 -0.01224085 -0.01224085
## 4: 15698.07 97.760 93.173 -0.01823377 -0.004940620 -0.01329315 -0.01329315
## 5: 16778.44 97.954 92.520 -0.02140343 -0.005469816 -0.01593362 -0.01593362
## 6: 18398.23 98.015 91.960 -0.02243751 -0.006263614 -0.01617390 -0.01617390
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04791 0.0003965 NA 36 28.5 1.013253 -0.1737357
## 2: %Air sec 0.04791 0.0003965 NA 36 28.5 1.013253 -0.1671689
## 3: %Air sec 0.04791 0.0003965 NA 36 28.5 1.013253 -0.1337449
## 4: %Air sec 0.04791 0.0003965 NA 36 28.5 1.013253 -0.1452424
## 5: %Air sec 0.04791 0.0003965 NA 36 28.5 1.013253 -0.1740925
## 6: %Air sec 0.04791 0.0003965 NA 36 28.5 1.013253 -0.1767179
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -438.1733 NA mgO2/hr/kg -438.1733
## 2: -421.6114 NA mgO2/hr/kg -421.6114
## 3: -337.3137 NA mgO2/hr/kg -337.3137
## 4: -366.3113 NA mgO2/hr/kg -366.3113
## 5: -439.0732 NA mgO2/hr/kg -439.0732
## 6: -445.6945 NA mgO2/hr/kg -445.6945
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 5 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0003965 | ch4 | Asus | 0.04791 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 422.1727 | 0.1673915 | 0.9762 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 3.80
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 12 14 15 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.71
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 413.7272 -0.04925892 0.9891990 NA 7 51 6394.07
## 2: NA 2 412.7331 -0.04910325 0.9885540 NA 8 52 6395.43
## 3: NA 3 412.6128 -0.04908640 0.9885006 NA 6 50 6392.71
## 4: NA 4 411.1517 -0.04885610 0.9874014 NA 9 53 6396.82
## 5: NA 5 409.8964 -0.04866441 0.9867671 NA 5 49 6391.38
## ---
## 173: NA 173 303.4003 -0.03230390 0.9964752 NA 173 217 6620.85
## 174: NA 174 302.6528 -0.03219147 0.9964084 NA 174 218 6622.21
## 175: NA 175 302.2828 -0.03213576 0.9963483 NA 175 219 6623.56
## 176: NA 176 301.4831 -0.03201541 0.9961158 NA 176 220 6624.91
## 177: NA 177 301.0164 -0.03194495 0.9958738 NA 177 221 6626.25
## endtime oxy endoxy rate
## 1: 6454.07 98.592 95.903 -0.04925892
## 2: 6455.43 98.602 95.916 -0.04910325
## 3: 6452.71 98.591 95.916 -0.04908640
## 4: 6456.82 98.539 95.898 -0.04885610
## 5: 6451.38 98.630 95.998 -0.04866441
## ---
## 173: 6680.85 89.529 87.617 -0.03230390
## 174: 6682.21 89.502 87.572 -0.03219147
## 175: 6683.56 89.436 87.527 -0.03213576
## 176: 6684.91 89.393 87.514 -0.03201541
## 177: 6686.25 89.314 87.488 -0.03194495
##
## Regressions : 177 | Results : 177 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 177 adjusted rate(s):
## Rate : -0.04925892
## Adjustment : -0.0002379482
## Adjusted Rate : -0.04902097
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 177 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 176 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 413.7272 -0.04925892 0.989199 NA 7 51 6394.07
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 6454.07 98.592 95.903 -0.04925892 -0.0002379482 -0.04902097 -0.04902097
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04791 0.0003965 NA 36 28.5 1.013253 -0.5356088
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1350.842 NA mgO2/hr/kg -1350.842
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 5 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0003965 | ch4 | Asus | 0.04791 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 422.1727 | 0.1673915 | 0.9762 | 1350.842 | 0.5356088 | 0.989199 | 928.669 | 0.3682173 | ||
| ### Expor | ting data |
## Rows: 143 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): Clutch, Male, Female, Population, Chamber, System, Date_tested, Sw...
## dbl (15): Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Temperatur...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 6
mass = 0.0006030
chamber = "ch3"
Swim = "good/good"
chamber_vol = chamber3_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "08 May 2023 01 09PM/Oxygen"
experiment_mmr_date2_asus <- "08 May 2023 01 09PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.002039056
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.004963481
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.08
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.08
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 3 1 345.4604 -0.02593413 0.978 NA 803 918 9502.82
## 2: 17 1 595.4698 -0.02922355 0.989 NA 6220 6400 17063.17
## 3: 18 1 617.3156 -0.02953250 0.990 NA 6616 6796 17602.90
## 4: 19 1 618.4306 -0.02872800 0.993 NA 7013 7193 18142.79
## 5: 20 1 627.1526 -0.02838717 0.992 NA 7410 7590 18682.54
## 6: 21 1 619.2482 -0.02716218 0.985 NA 7807 7987 19223.37
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 9747.34 98.604 92.427 -0.02593413 -0.003373553 -0.02256058 -0.02256058
## 2: 17308.60 97.248 89.585 -0.02922355 -0.006137084 -0.02308646 -0.02308646
## 3: 17847.94 97.229 90.205 -0.02953250 -0.006334288 -0.02319821 -0.02319821
## 4: 18387.35 97.295 90.561 -0.02872800 -0.006531534 -0.02219646 -0.02219646
## 5: 18927.64 96.972 90.178 -0.02838717 -0.006728915 -0.02165825 -0.02165825
## 6: 19468.83 97.260 91.051 -0.02716218 -0.006926659 -0.02023552 -0.02023552
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04551 0.000603 NA 36 28.5 1.013253 -0.2341514
## 2: %Air sec 0.04551 0.000603 NA 36 28.5 1.013253 -0.2396094
## 3: %Air sec 0.04551 0.000603 NA 36 28.5 1.013253 -0.2407692
## 4: %Air sec 0.04551 0.000603 NA 36 28.5 1.013253 -0.2303723
## 5: %Air sec 0.04551 0.000603 NA 36 28.5 1.013253 -0.2247863
## 6: %Air sec 0.04551 0.000603 NA 36 28.5 1.013253 -0.2100200
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -388.3107 NA mgO2/hr/kg -388.3107
## 2: -397.3622 NA mgO2/hr/kg -397.3622
## 3: -399.2856 NA mgO2/hr/kg -399.2856
## 4: -382.0436 NA mgO2/hr/kg -382.0436
## 5: -372.7800 NA mgO2/hr/kg -372.7800
## 6: -348.2919 NA mgO2/hr/kg -348.2919
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 6 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.000603 | ch3 | Asus | 0.04551 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 387.9564 | 0.2339377 | 0.9884 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 3.80
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 6 7 8 9 11 13 14 15 16 17 18 19 21 22 24 25
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.68
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 657.9158 -0.07992860 0.9842585 NA 11 55 7014.97
## 2: NA 2 657.6453 -0.07989121 0.9842019 NA 10 54 7013.47
## 3: NA 3 656.9984 -0.07979789 0.9840887 NA 12 56 7016.35
## 4: NA 4 656.1663 -0.07967945 0.9839622 NA 13 57 7017.73
## 5: NA 5 655.9292 -0.07964896 0.9836147 NA 9 53 7012.11
## ---
## 173: NA 173 352.1695 -0.03704217 0.9961526 NA 157 201 7213.96
## 174: NA 174 351.1415 -0.03689964 0.9958153 NA 160 204 7218.03
## 175: NA 175 351.1377 -0.03689925 0.9958162 NA 159 203 7216.69
## 176: NA 176 350.9649 -0.03687562 0.9957717 NA 158 202 7215.33
## 177: NA 177 350.9446 -0.03687249 0.9958065 NA 161 205 7219.39
## endtime oxy endoxy rate
## 1: 7074.97 97.066 92.570 -0.07992860
## 2: 7073.47 97.061 92.698 -0.07989121
## 3: 7076.35 97.073 92.426 -0.07979789
## 4: 7077.73 96.985 92.296 -0.07967945
## 5: 7072.11 97.106 92.822 -0.07964896
## ---
## 173: 7273.96 84.939 82.818 -0.03704217
## 174: 7278.03 84.802 82.606 -0.03689964
## 175: 7276.69 84.824 82.663 -0.03689925
## 176: 7275.33 84.853 82.761 -0.03687562
## 177: 7279.39 84.723 82.542 -0.03687249
##
## Regressions : 177 | Results : 177 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 177 adjusted rate(s):
## Rate : -0.0799286
## Adjustment : -0.002039056
## Adjusted Rate : -0.07788954
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 177 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 176 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 657.9158 -0.0799286 0.9842585 NA 11 55 7014.97
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 7074.97 97.066 92.57 -0.0799286 -0.002039056 -0.07788954 -0.07788954
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04551 0.000603 NA 36 28.5 1.013253 -0.8083986
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1340.628 NA mgO2/hr/kg -1340.628
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 6 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.000603 | ch3 | Asus | 0.04551 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 387.9564 | 0.2339377 | 0.9884 | 1340.628 | 0.8083986 | 0.9842585 | 952.6715 | 0.5744609 | ||
| ### Expor | ting data |
## Rows: 144 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): Clutch, Male, Female, Population, Chamber, System, Date_tested, Sw...
## dbl (15): Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Temperatur...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 7
mass = 0.0005944
chamber = "ch2"
Swim = "good/good"
chamber_vol = chamber2_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "08 May 2023 01 21PM/Oxygen"
experiment_mmr_date2_asus <- "08 May 2023 01 21PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.000218146
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.002001839
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.08
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.08
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## Warning: adjust_rate: background rates in 'by' and 'by2' differ in sign (i.e. one is +ve, one is -ve).
## Ensure this is correct. The 'linear' adjustment has been performed regardless.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 3 rate(s) removed, 18 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 12 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 3 1 283.8107 -0.01941981 0.983 NA 803 918 9502.82
## 2: 8 1 400.5266 -0.02465756 0.972 NA 2718 2886 12203.14
## 3: 9 1 430.5860 -0.02599828 0.976 NA 3050 3230 12743.14
## 4: 17 1 565.9083 -0.02736818 0.987 NA 6220 6400 17063.17
## 5: 19 1 572.5227 -0.02607787 0.979 NA 7013 7193 18142.79
## 6: 20 1 576.3566 -0.02556224 0.986 NA 7410 7590 18682.54
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 9747.34 99.328 94.217 -0.01941981 -0.000794895 -0.01862491 -0.01862491
## 2: 12449.12 99.072 93.572 -0.02465756 -0.001544338 -0.02311323 -0.02311323
## 3: 12988.69 99.193 93.269 -0.02599828 -0.001694108 -0.02430417 -0.02430417
## 4: 17308.60 98.909 92.804 -0.02736818 -0.002892742 -0.02447544 -0.02447544
## 5: 18387.35 98.676 92.593 -0.02607787 -0.003192176 -0.02288570 -0.02288570
## 6: 18927.64 98.458 91.933 -0.02556224 -0.003342012 -0.02222023 -0.02222023
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04573 0.0005944 NA 36 28.5 1.013253 -0.1942384
## 2: %Air sec 0.04573 0.0005944 NA 36 28.5 1.013253 -0.2410468
## 3: %Air sec 0.04573 0.0005944 NA 36 28.5 1.013253 -0.2534671
## 4: %Air sec 0.04573 0.0005944 NA 36 28.5 1.013253 -0.2552533
## 5: %Air sec 0.04573 0.0005944 NA 36 28.5 1.013253 -0.2386739
## 6: %Air sec 0.04573 0.0005944 NA 36 28.5 1.013253 -0.2317338
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -326.7806 NA mgO2/hr/kg -326.7806
## 2: -405.5296 NA mgO2/hr/kg -405.5296
## 3: -426.4251 NA mgO2/hr/kg -426.4251
## 4: -429.4302 NA mgO2/hr/kg -429.4302
## 5: -401.5375 NA mgO2/hr/kg -401.5375
## 6: -389.8616 NA mgO2/hr/kg -389.8616
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 7 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0005944 | ch2 | Asus | 0.04573 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 410.5568 | 0.244035 | 0.98 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 3.80
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 3 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 22 23 24
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.52
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 541.1375 -0.05684875 0.9987050 NA 163 208 7923.37
## 2: NA 2 540.9453 -0.05682398 0.9986484 NA 164 209 7924.73
## 3: NA 3 539.8081 -0.05668229 0.9982821 NA 162 207 7922.01
## 4: NA 4 539.7158 -0.05666890 0.9983357 NA 165 210 7926.10
## 5: NA 5 537.4156 -0.05637942 0.9978999 NA 166 211 7927.44
## ---
## 173: NA 173 280.1054 -0.02393596 0.9601557 NA 130 175 7878.65
## 174: NA 174 278.7590 -0.02376205 0.9630101 NA 126 171 7873.21
## 175: NA 175 277.8061 -0.02364426 0.9646355 NA 129 174 7877.30
## 176: NA 176 277.1007 -0.02355316 0.9660353 NA 127 172 7874.55
## 177: NA 177 276.9030 -0.02352909 0.9664221 NA 128 173 7875.92
## endtime oxy endoxy rate
## 1: 7983.37 90.598 87.378 -0.05684875
## 2: 7984.73 90.585 87.333 -0.05682398
## 3: 7982.01 90.635 87.412 -0.05668229
## 4: 7986.10 90.551 87.280 -0.05666890
## 5: 7987.44 90.528 87.219 -0.05637942
## ---
## 173: 7938.65 91.697 89.861 -0.02393596
## 174: 7933.21 91.977 90.201 -0.02376205
## 175: 7937.30 91.763 89.949 -0.02364426
## 176: 7934.55 91.907 90.107 -0.02355316
## 177: 7935.92 91.841 90.024 -0.02352909
##
## Regressions : 177 | Results : 177 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 177 adjusted rate(s):
## Rate : -0.05684875
## Adjustment : 0.000218146
## Adjusted Rate : -0.0570669
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 13 rate(s) removed, 164 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 163 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 541.1375 -0.05684875 0.998705 NA 163 208 7923.37
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 7983.37 90.598 87.378 -0.05684875 0.000218146 -0.0570669 -0.0570669
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04573 0.0005944 NA 36 28.5 1.013253 -0.5951481
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1001.259 NA mgO2/hr/kg -1001.259
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 7 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0005944 | ch2 | Asus | 0.04573 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 410.5568 | 0.244035 | 0.98 | 1001.259 | 0.5951481 | 0.998705 | 590.7018 | 0.3511131 | ||
| ### Expor | ting data |
## Rows: 145 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): Clutch, Male, Female, Population, Chamber, System, Date_tested, Sw...
## dbl (15): Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Temperatur...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 8
mass = 0.0006489
chamber = "ch1"
Swim = "good/good"
chamber_vol = chamber1_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "08 May 2023 01 32PM/Oxygen"
experiment_mmr_date2_asus <- "08 May 2023 01 32PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.001684191
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.004073995
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.08
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.08
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 12 1 540.7853 -0.03090593 0.999 NA 4238 4418 14362.96
## 2: 14 1 566.4278 -0.03040396 0.999 NA 5031 5211 15443.31
## 3: 16 1 616.5114 -0.03145104 0.998 NA 5823 6003 16522.79
## 4: 17 1 605.3139 -0.02981019 0.998 NA 6220 6400 17063.17
## 5: 18 1 645.2569 -0.03115407 0.998 NA 6616 6796 17602.90
## 6: 21 1 705.2452 -0.03163181 0.996 NA 7807 7987 19223.37
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 14608.49 96.725 89.264 -0.03090593 -0.004226543 -0.02667939 -0.02667939
## 2: 15688.55 96.804 89.410 -0.03040396 -0.004549187 -0.02585477 -0.02585477
## 3: 16767.57 96.726 89.117 -0.03145104 -0.004871547 -0.02657949 -0.02657949
## 4: 17308.60 96.475 89.302 -0.02981019 -0.005033049 -0.02477714 -0.02477714
## 5: 17847.94 96.847 89.206 -0.03115407 -0.005194202 -0.02595986 -0.02595986
## 6: 19468.83 96.945 89.147 -0.03163181 -0.005678280 -0.02595353 -0.02595353
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04565 0.0006489 NA 36 28.5 1.013253 -0.2777514
## 2: %Air sec 0.04565 0.0006489 NA 36 28.5 1.013253 -0.2691665
## 3: %Air sec 0.04565 0.0006489 NA 36 28.5 1.013253 -0.2767114
## 4: %Air sec 0.04565 0.0006489 NA 36 28.5 1.013253 -0.2579476
## 5: %Air sec 0.04565 0.0006489 NA 36 28.5 1.013253 -0.2702606
## 6: %Air sec 0.04565 0.0006489 NA 36 28.5 1.013253 -0.2701947
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -428.0342 NA mgO2/hr/kg -428.0342
## 2: -414.8043 NA mgO2/hr/kg -414.8043
## 3: -426.4315 NA mgO2/hr/kg -426.4315
## 4: -397.5152 NA mgO2/hr/kg -397.5152
## 5: -416.4904 NA mgO2/hr/kg -416.4904
## 6: -416.3889 NA mgO2/hr/kg -416.3889
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 8 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0006489 | ch1 | Asus | 0.04565 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 420.4299 | 0.2728169 | 0.998 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 4.08
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.67
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 614.3791 -0.06165932 0.9966487 NA 83 127 8490.37
## 2: NA 2 613.3180 -0.06153494 0.9965751 NA 82 126 8488.99
## 3: NA 3 613.3129 -0.06153401 0.9965555 NA 84 128 8491.72
## 4: NA 4 611.5820 -0.06133146 0.9963436 NA 81 125 8487.62
## 5: NA 5 610.7867 -0.06123755 0.9964635 NA 85 129 8493.06
## ---
## 173: NA 173 476.1390 -0.04549624 0.9928812 NA 131 175 8556.01
## 174: NA 174 474.4921 -0.04530514 0.9936108 NA 132 176 8557.38
## 175: NA 175 474.0840 -0.04525871 0.9938253 NA 135 179 8561.51
## 176: NA 176 473.6532 -0.04520785 0.9938183 NA 133 177 8558.78
## 177: NA 177 472.8977 -0.04512034 0.9940317 NA 134 178 8560.15
## endtime oxy endoxy rate
## 1: 8550.37 90.821 87.171 -0.06165932
## 2: 8548.99 90.849 87.272 -0.06153494
## 3: 8551.72 90.787 87.152 -0.06153401
## 4: 8547.62 90.916 87.281 -0.06133146
## 5: 8553.06 90.760 87.090 -0.06123755
## ---
## 173: 8616.01 87.056 84.054 -0.04549624
## 174: 8617.38 86.985 83.995 -0.04530514
## 175: 8621.51 86.638 83.803 -0.04525871
## 176: 8618.78 86.839 83.965 -0.04520785
## 177: 8620.15 86.779 83.891 -0.04512034
##
## Regressions : 177 | Results : 177 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 177 adjusted rate(s):
## Rate : -0.06165932
## Adjustment : -0.001684191
## Adjusted Rate : -0.05997513
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 177 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 176 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 614.3791 -0.06165932 0.9966487 NA 83 127 8490.37
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 8550.37 90.821 87.171 -0.06165932 -0.001684191 -0.05997513 -0.05997513
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04565 0.0006489 NA 36 28.5 1.013253 -0.6243837
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -962.2187 NA mgO2/hr/kg -962.2187
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 092 | 8 | CSUD002 | CSUD213 | Sudbury reef | 213 | 0.0006489 | ch1 | Asus | 0.04565 | 2023-05-08 | 2024-06-18 | good/good | 36 | 28.5 | 420.4299 | 0.2728169 | 0.998 | 962.2187 | 0.6243837 | 0.9966487 | 541.7888 | 0.3515668 | ||
| ### Expor | ting data |
## Rows: 146 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): Clutch, Male, Female, Population, Chamber, System, Date_tested, Sw...
## dbl (15): Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Temperatur...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.